<template>
	<div>
		<!-- 个人中心-线下实体店 -->
		<a-divider orientation="left">线下实体店录入</a-divider>  
		<router-link to='/addShop'><a-button >添加</a-button></router-link>
		<a-table class='mt28'  :columns="columns" :data-source="shopList"  :row-key="record => record.code">
	    	<span slot='createTime' slot-scope='text,record'>{{text | formatDate}}</span>
		    <span slot="action" slot-scope="text, record">
		      <router-link  :to='{ path:"/addShop",query:{code:record.code} }'  class='color-blue'>查看</router-link>
		      <a-divider type="vertical" /> 
		      <a-popconfirm
				    title="确定要删除这条？"
				    ok-text="Yes"
				    cancel-text="No"
				    @confirm="confirmdelShop(record.code)"
				    @cancel="cancel"
				  >
				    <a class='color-red'>删除</a>
			  </a-popconfirm>
		    </span>
	  	</a-table>

		<!-- 个人中心-设置模块 -->
		<a-divider orientation="left">设置模块</a-divider>  
		<router-link to='/showText'><a-button >添加自定义富文本项</a-button></router-link>
		<a-list class='mt28'  bordered :data-source="settingList" >
	      <a-list-item slot="renderItem" slot-scope="item, index">
	      	<router-link :to='{"path":"/showText",query:{code:item.code}}' class='color-blue pr60'>{{ item.termsName }}</router-link>
	        
	        <a-popconfirm
			    title="确定要删除这条？"
			    ok-text="Yes"
			    cancel-text="No"
			    @confirm="confirmdel(item.code)"
			    @cancel="cancel"
			  >
			    <a-icon type="delete" style='color:red' class='fr cursor' />
			</a-popconfirm>
	      </a-list-item>
	    </a-list>
 
	</div>
</template>

<script type="text/javascript">
	const columns = 
	[
	  {
	  	title:'店名',
	    dataIndex: 'shopName',
	    key: 'shopName'
	  },
	  {
	  	title:'地址',
	  	dataIndex:'address',
	  	key:'address'
	  },
	  {
	  	title:'联系方式',
	  	dataIndex:'phone',
	  	key:'phone'
	  },
	  {
	  	title:'创建时间',
	  	dataIndex:'createTime',
	  	key:'createTime', 
    	scopedSlots: { customRender: 'createTime' }
	  },
	  {
	  	title:'操作',
	  	dataIndex:'action',
	  	key:'action', 
    	scopedSlots: { customRender: 'action' }
	  }

	]
	import { listSetting,delListSetting,listShop,delShop } from '@/api/minipro/userCenter'
	export default{
		name:'userSetting',
		data(){
			return {
				addRichItem:false,
				columns,
				shopList:[],
				settingList:[], 
			}
			
		},
		created(){
			this.pageInit()
		},

		methods:{
			pageInit(){
				listSetting().then((res)=>{
					this.settingList = res.data.dataList
				})
				listShop().then((res)=>{
					this.shopList = res.data.dataList
				})
			},
			addRichtext(){
				 
			},
			confirmdel(code){

				delListSetting(code).then((res)=>{
					if(res.data.flag == true){
						this.pageInit()
					}
				})
			},

			confirmdelShop(code){
				delShop(code).then((res)=>{
					console.log(res)
					if(res.data.flag == true){
						this.pageInit()
					}
				})
			}
		}
	}
</script>

<style scoped="scoped">
	
</style>